package io.seata.storage.web;

import io.seata.common.dto.StorageDTO;
import io.seata.common.response.ObjectResponse;
import io.seata.storage.service.StorageService;
import io.seata.storage.service.StorageTCCService;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ZengRJ
 */
@RestController
@RequestMapping("storage")
public class StorageController {

    @Resource
    private StorageService storageService;

    @Resource
    private StorageTCCService storageTCCService;

    /**
     * 扣减库存
     */
    @PutMapping("/deduct")
    public ObjectResponse deduct(@RequestBody StorageDTO storageDTO){
//        return storageService.deduct(storageDTO);
        return storageTCCService.deduct(storageDTO);
    }
}
